load("//bazel:mongo_src_rules.bzl", "mongo_cc_library", "mongo_cc_unit_test")

package(default_visibility = ["//visibility:public"])

exports_files(
    glob([
        "*.h",
        "*.cpp",
    ]),
)

mongo_cc_library(
    name = "memory_tracking",
    srcs = [
        "operation_memory_usage_tracker.cpp",
    ],
    deps = [
        "//src/mongo/db:commands",
        "//src/mongo/db:server_feature_flags",
        "//src/mongo/db:service_context",
    ],
)

mongo_cc_unit_test(
    name = "memory_tracking_test",
    srcs = [
        "memory_usage_tracker_test.cpp",
        "operation_memory_usage_tracker_test.cpp",
    ],
    tags = ["mongo_unittest_second_group"],
    deps = [
        ":memory_tracking",
        "//src/mongo/db:service_context_test_fixture",
        "//src/mongo/db/pipeline:aggregation_context_fixture",
        "//src/mongo/db/pipeline:document_source_mock",
    ],
)
